using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using TTDotNet.Engine.GUI.Windows;
using TTDotNet.Engine.ThreeDEngine;

namespace TTDotNet.Engine.GUI
{
    public class ResizeButton : GameButton
    {
        private Window parentWindow;

        private int _xOffset;
        private int _yOffset;
        private bool downInRange;

        public ResizeButton(RectangleF screenRect, GameTexture up, GameTexture down, Window window) : base(screenRect, "", 1, Color.Black, "Arial", up, down)
        {
            this.parentWindow = window;
        }

        protected override void OnMouseDown(Point cursor, bool[] buttons)
        {
            Point mouseLoc = System.Windows.Forms.Cursor.Position;

            if (!downInRange)
            {
                if (Contains(cursor))
                {
                    downInRange = true;
                }
                else
                {
                    downInRange = false;
                }
            }

            if (downInRange)
            {

                _xOffset = cursor.X - _touchDownPoint.X;
                _yOffset = cursor.Y - _touchDownPoint.Y;

                _touchDownPoint.X += _xOffset;
                _touchDownPoint.Y += _yOffset;

                if (parentWindow.ResizeTo(parentWindow.Area.Width + _xOffset, parentWindow.Area.Height + _yOffset))
                {

                }
                else
                {
                }

            }
        }

        protected override void OnMouseRelease(Point cursor)
        {
            downInRange = false;
        }
    }
}
